/*
 * This file is part of the Sx Framework Library.
 * 
 * Copyright (C) 2013 University of Colorado Denver
 * <min.choi@ucdenver.edu> <shane.transue@ucdenver.edu>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy 
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 * copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 */
#ifndef SX_OBJ_FACE_H
#define SX_OBJ_FACE_H

#include <sxMath.h>
#include <sxBufferUtilities.h>

namespace Sx {
namespace Graphics {
namespace File {

/*
 * These typedefs define the maximum number of materials, groups,
 * and smoothing groups a single mesh can have. To increase the
 * maximum number, change their underlying datatypes in the 
 * OBJ_IndexType typedef (Default is unsigned int).
 */
typedef unsigned int OBJ_IndexType;
typedef OBJ_IndexType OBJ_MaterialIndex;
typedef OBJ_IndexType OBJ_GroupIndex;
typedef OBJ_IndexType OBJ_SmoothingGroupIndex;

/*
 * Structure used to store a single vertex, normal, texture
 * coordinate triple.
 */
struct OBJ_VertexIndiceSet {
	unsigned int vertex, normal, textureCoord;
};

/*
 * A Face is defined as set of indices that access a set of vertices that 
 * are contained in an object that form a polygon shape, quad, or triangle.
 * Generally this class can be constructed during the parsing of an OBJ
 * file and the indices are added as the face is parsed. This allows for
 * faces with n sides. This structure is intended to be used with the 
 * OBJ_File class.
 */
struct OBJ_Face {
	OBJ_Face() {
		this->faceType = Math::TRIANGLE;
		this->smoothingGroupIndex = 0;
		this->groupIndex = 0;
		this->materialIndex = 0;
	}

	OBJ_Face(Math::PrimitiveType faceType, OBJ_SmoothingGroupIndex smoothingGroupIndex, OBJ_GroupIndex groupIndex, OBJ_MaterialIndex materialIndex) {
		this->faceType = faceType;
		this->smoothingGroupIndex = smoothingGroupIndex;
		this->groupIndex = groupIndex;
		this->materialIndex = materialIndex;
	}

	/*
	 * Provides a description of the type of face.
	 */
	Math::PrimitiveType faceType;

	/*
	 * Indices into a vertex array that holds the vertices bound
	 * to this face.
	 */
	Util::IndexArray vertexIndices;
	Util::IndexArray textureIndices;
	Util::IndexArray normalIndices;

	/*
	 * Indicates the smoothing group of this face. If the smoothing
	 * group for this face is turned off then this value should be -1.
	 */
	OBJ_SmoothingGroupIndex smoothingGroupIndex;

	/*
	 * The index of the group defined in the OBJ_File groups map. This
	 * index maps to this groups string representation contained in the
	 * OBJ_File groups map.
	 */
	OBJ_GroupIndex groupIndex;

	/*
	 * The index of the material for this face defined in the OBJ_File
	 * materials map. This index maps to a string value of the name of
	 * the material that should be applied to this face.
	 */
	OBJ_MaterialIndex materialIndex;
};

}

}

}

#endif
